package org.noip.milhous.clause;

import org.noip.milhous.FieldName;
import org.noip.milhous.SQLInterface;

public class On implements SQLInterface
{
	private String SQL;

	public On(String leftTableName, String leftVar, String rightTableName, String rightVar)
		{
			super();
			SQL = " ON " + Utilities.quoteString(leftTableName) + "." + Utilities.quoteString(leftVar) + " = " + Utilities.quoteString(rightTableName) + "." + Utilities.quoteString(rightVar) + " ";
		}

	public On(Object left, Object right)
		{
			SQL = " ON " + Utilities.getField(left) + " = " + Utilities.getField(right) + " ";
		}

	public static String getFieldName(Object o)
		{
			String result = null;
			if (o instanceof FieldName)
				{
					result = ((FieldName) o).getDatabaseFieldName();
				}
			else
				{

				}
			return result;
		}

	public String toInternalSQL()
		{
			return SQL;
		}

	public String toSQL()
		{
			return toInternalSQL();
		}
}
